import Vue from 'vue';
import VueRouter from 'vue-router';
import index from '../views/index.vue';
import login from '../views/login.vue';
import forgot from '../views/forgot.vue';
import register from '../views/register.vue';
Vue.use(VueRouter)

const routes = [
    // 主页
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            index: 0,
            title: '首页'
        }
    },

    // 登录
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: {
            index: 0,
            title: '登录'
        }
    },

            // 注册
        {
            path: '/register',
            name: 'register',
            component: register,
            meta: {
                index: 0,
                title: '注册'
            }
        },
    	
	
    // 忘记密码
    {
        path: '/forgot',
        name: "forgot",
        component: forgot,
        meta: {
            index: 0,
            title: '忘记密码'
        }
    },

    // 修改密码
    {
        path: '/user/password',
        name: "password",
        component: () => import("../views/user/password.vue"),
        meta: {
            index: 0,
            title: '修改密码'
        }
    },

    // 视频播放页
    {
        path: "/media/video",
        name: "video",
        component: () => import('../views/media/video.vue'),
        meta: {
            index: 0,
            title: "视频"
        }
    },

    // 音频播放页
    {
        path: "/media/audio",
        name: "audio",
        component: () => import('../views/media/audio.vue'),
        meta: {
            index: 0,
            title: "音频"
        }
    },

            // 权限路由
        {
            path: '/auth/table',
            name: 'auth_table',
            component: () => import('../views/auth/table.vue'),
            meta: {
                index: 0,
                title: '权限列表'
            }
        },
        {
            path: '/auth/view',
            name: 'auth_view',
            component: () => import('../views/auth/view.vue'),
            meta: {
                index: 0,
                title: '权限详情'
            }
        },
    
    
                // 轮播图路由
        {
            path: '/slides/table',
            name: 'slides_table',
            component: () => import('../views/slides/table.vue'),
            meta: {
                index: 0,
                title: '轮播图列表'
            }
        },
        {
            path: '/slides/view',
            name: 'slides_view',
            component: () => import('../views/slides/view.vue'),
            meta: {
                index: 0,
                title: '轮播图详情'
            }
        },
                    // 文章路由
            {
                path: '/article/table',
                name: 'article_table',
                component: () => import('../views/article/table.vue'),
                meta: {
                    index: 0,
                    title: '民宿资讯列表'
                }
            },
            {
                path: '/article/view',
                name: 'article_view',
                component: () => import('../views/article/view.vue'),
                meta: {
                    index: 0,
                    title: '民宿资讯详情'
                }
            },

            // 文章分类路由
            {
                path: '/article_type/table',
                name: 'article_type_table',
                component: () => import('../views/article_type/table.vue'),
                meta: {
                    index: 0,
                    title: '民宿资讯分类列表'
                }
            },
            {
                path: '/article_type/view',
                name: 'article_type_view',
                component: () => import('../views/article_type/view.vue'),
                meta: {
                    index: 0,
                    title: '民宿资讯分类详情'
                }
            },
                            
    
    
            // 公告路由
        {
            path: '/notice/table',
            name: 'notice_table',
            component: () => import('../views/notice/table.vue'),
            meta: {
                index: 0,
                title: '通知公告列表'
            }
        },
        {
            path: '/notice/view',
            name: 'notice_view',
            component: () => import('../views/notice/view.vue'),
            meta: {
                index: 0,
                title: '通知公告详情'
            }
        },
            	    
            // 评论路由
        {
            path: '/comment/table',
            name: 'comment_table',
            component: () => import('../views/comment/table.vue'),
            meta: {
                index: 0,
                title: '评论列表'
            }
        },
        {
            path: '/comment/view',
            name: 'comment_view',
            component: () => import('../views/comment/view.vue'),
            meta: {
                index: 0,
                title: '评论详情'
            }
        },
        	            // 普通用户路由
        {
            path: '/ordinary_users/table',
            name: 'ordinary_users_table',
            component: () => import('../views/ordinary_users/table.vue'),
            meta: {
                index: 0,
                title: '普通用户列表'
            }
        },
        {
            path: '/ordinary_users/view',
            name: 'ordinary_users_view',
            component: () => import('../views/ordinary_users/view.vue'),
            meta: {
                index: 0,
                title: '普通用户详情'
            }
        },
						            // 商家用户路由
        {
            path: '/merchant_users/table',
            name: 'merchant_users_table',
            component: () => import('../views/merchant_users/table.vue'),
            meta: {
                index: 0,
                title: '商家用户列表'
            }
        },
        {
            path: '/merchant_users/view',
            name: 'merchant_users_view',
            component: () => import('../views/merchant_users/view.vue'),
            meta: {
                index: 0,
                title: '商家用户详情'
            }
        },
						            // 员工用户路由
        {
            path: '/employee_user/table',
            name: 'employee_user_table',
            component: () => import('../views/employee_user/table.vue'),
            meta: {
                index: 0,
                title: '员工用户列表'
            }
        },
        {
            path: '/employee_user/view',
            name: 'employee_user_view',
            component: () => import('../views/employee_user/view.vue'),
            meta: {
                index: 0,
                title: '员工用户详情'
            }
        },
						            // 房间打扫路由
        {
            path: '/room_cleaning/table',
            name: 'room_cleaning_table',
            component: () => import('../views/room_cleaning/table.vue'),
            meta: {
                index: 0,
                title: '房间打扫列表'
            }
        },
        {
            path: '/room_cleaning/view',
            name: 'room_cleaning_view',
            component: () => import('../views/room_cleaning/view.vue'),
            meta: {
                index: 0,
                title: '房间打扫详情'
            }
        },
						            // 地区名称路由
        {
            path: '/region_name/table',
            name: 'region_name_table',
            component: () => import('../views/region_name/table.vue'),
            meta: {
                index: 0,
                title: '地区名称列表'
            }
        },
        {
            path: '/region_name/view',
            name: 'region_name_view',
            component: () => import('../views/region_name/view.vue'),
            meta: {
                index: 0,
                title: '地区名称详情'
            }
        },
						            // 热门景点路由
        {
            path: '/popular_attractions/table',
            name: 'popular_attractions_table',
            component: () => import('../views/popular_attractions/table.vue'),
            meta: {
                index: 0,
                title: '热门景点列表'
            }
        },
        {
            path: '/popular_attractions/view',
            name: 'popular_attractions_view',
            component: () => import('../views/popular_attractions/view.vue'),
            meta: {
                index: 0,
                title: '热门景点详情'
            }
        },
						            // 民宿信息路由
        {
            path: '/homestay_information/table',
            name: 'homestay_information_table',
            component: () => import('../views/homestay_information/table.vue'),
            meta: {
                index: 0,
                title: '民宿信息列表'
            }
        },
        {
            path: '/homestay_information/view',
            name: 'homestay_information_view',
            component: () => import('../views/homestay_information/view.vue'),
            meta: {
                index: 0,
                title: '民宿信息详情'
            }
        },
						            // 民宿订单路由
        {
            path: '/homestay_orders/table',
            name: 'homestay_orders_table',
            component: () => import('../views/homestay_orders/table.vue'),
            meta: {
                index: 0,
                title: '民宿订单列表'
            }
        },
        {
            path: '/homestay_orders/view',
            name: 'homestay_orders_view',
            component: () => import('../views/homestay_orders/view.vue'),
            meta: {
                index: 0,
                title: '民宿订单详情'
            }
        },
						            // 取消订单路由
        {
            path: '/cancellation_of_order/table',
            name: 'cancellation_of_order_table',
            component: () => import('../views/cancellation_of_order/table.vue'),
            meta: {
                index: 0,
                title: '取消订单列表'
            }
        },
        {
            path: '/cancellation_of_order/view',
            name: 'cancellation_of_order_view',
            component: () => import('../views/cancellation_of_order/view.vue'),
            meta: {
                index: 0,
                title: '取消订单详情'
            }
        },
						            // 续房订单路由
        {
            path: '/renewal_order/table',
            name: 'renewal_order_table',
            component: () => import('../views/renewal_order/table.vue'),
            meta: {
                index: 0,
                title: '续房订单列表'
            }
        },
        {
            path: '/renewal_order/view',
            name: 'renewal_order_view',
            component: () => import('../views/renewal_order/view.vue'),
            meta: {
                index: 0,
                title: '续房订单详情'
            }
        },
						            // 用户评价路由
        {
            path: '/user_evaluate/table',
            name: 'user_evaluate_table',
            component: () => import('../views/user_evaluate/table.vue'),
            meta: {
                index: 0,
                title: '用户评价列表'
            }
        },
        {
            path: '/user_evaluate/view',
            name: 'user_evaluate_view',
            component: () => import('../views/user_evaluate/view.vue'),
            meta: {
                index: 0,
                title: '用户评价详情'
            }
        },
						            // 民宿餐饮路由
        {
            path: '/homestay_and_catering/table',
            name: 'homestay_and_catering_table',
            component: () => import('../views/homestay_and_catering/table.vue'),
            meta: {
                index: 0,
                title: '民宿餐饮列表'
            }
        },
        {
            path: '/homestay_and_catering/view',
            name: 'homestay_and_catering_view',
            component: () => import('../views/homestay_and_catering/view.vue'),
            meta: {
                index: 0,
                title: '民宿餐饮详情'
            }
        },
						            // 商家账单路由
        {
            path: '/merchant_billing/table',
            name: 'merchant_billing_table',
            component: () => import('../views/merchant_billing/table.vue'),
            meta: {
                index: 0,
                title: '商家账单列表'
            }
        },
        {
            path: '/merchant_billing/view',
            name: 'merchant_billing_view',
            component: () => import('../views/merchant_billing/view.vue'),
            meta: {
                index: 0,
                title: '商家账单详情'
            }
        },
						            // 餐饮订单路由
        {
            path: '/catering_orders/table',
            name: 'catering_orders_table',
            component: () => import('../views/catering_orders/table.vue'),
            meta: {
                index: 0,
                title: '餐饮订单列表'
            }
        },
        {
            path: '/catering_orders/view',
            name: 'catering_orders_view',
            component: () => import('../views/catering_orders/view.vue'),
            meta: {
                index: 0,
                title: '餐饮订单详情'
            }
        },
						    			// 操作日志路由
		{
		    path: '/operation_log/table',
		    name: 'operation_log_table',
		    component: () => import('../views/operation_log/table.vue'),
		    meta: {
		        index: 0,
		        title: '操作日志'
		    }
		},
	    // 用户路由
    {
        path: '/user/table',
        name: 'user_table',
        component: () => import('../views/user/table.vue'),
        meta: {
            index: 0,
            title: '用户列表'
        }
    },
    {
        path: '/user/view',
        name: 'user_view',
        component: () => import('../views/user/view.vue'),
        meta: {
            index: 0,
            title: '用户详情'
        }
    },
    {
        path: '/user/info',
        name: 'user_info',
        component: () => import('../views/user/info.vue'),
        meta: {
            index: 0,
            title: '个人信息'
        }
    },
    // 用户组路由
    {
        path: '/user_group/table',
        name: 'user_group_table',
        component: () => import('../views/user_group/table.vue'),
        meta: {
            index: 0,
            title: '用户组列表'
        }
    },
    {
        path: '/user_group/view',
        name: 'user_group_view',
        component: () => import('../views/user_group/view.vue'),
        meta: {
            index: 0,
            title: '用户组详情'
        }
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    let token = to.query.token;
    if (token) {
        $.db.set("token", token, 120);
    }
    next();
})

router.afterEach((to, from, next) => {
    let title = "在线民宿预定管理系统-admin";
    document.title = title;
})

export default router
